<%@ page language="java" contentType="text/html; charset=GB18030"
	pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="ase.assignment.sts.api.*"%>
<%@page import="ase.assignment.sts.utils.STSConstants"%>
<%@page import="ase.assignment.sts.beans.*"%>
<html>
<head>
<title>Portfolio</title>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="infodiv"><a href="#">Signin</a>&nbsp;|&nbsp;<a
	href="#">help</a>&nbsp;|&nbsp;<a href="#">My Account</a>&nbsp;|&nbsp;<a
	href="index.html">home</a></div>

<table id="mt" cellspacing="0" cellpadding="0" width="100%" border="0">
	<tr>
		<th class="activeth">
		<div class="activetab"><a onclick="cancelBubble=true;"
			href="portfolio.jsp">Portfolio Info</a></div>
		</th>
		<td>&nbsp;&nbsp;</td>

		<th class="inactiveth">
		<div class="inactivetab"><a onclick="cancelBubble=true;"
			href="stock.jsp">Stock Info</a></div>
		</th>
		<td>&nbsp;&nbsp;</td>


		<th class="inactiveth">
		<div class="inactivetab"><a onclick="cancelBubble=true;"
			href="account.jsp">Account</a></div>
		</th>
		<td>&nbsp;&nbsp;</td>

		<th class="inactiveth">
		<div class="inactivetab"><a onclick="cancelBubble=true;"
			href="portfolio_chart.jsp">Summary Chart</a></div>
		</th>
		<td>&nbsp;&nbsp;</td>

		<td width="100%">&nbsp;</td>
	</tr>
</table>

<table cellspacing="0" cellpadding="0" width="100%" align="center"
	border="0" style="background-color: #c3d9ff;">
	<tr>
		<td height="4px" align="right"
			style="padding: 0px; vertical-align: top"></td>
	</tr>
</table>

<!-- this table shows the all portfolios -->

<table id="ct" width="100%" cellpadding="2" cellspacing="0" class="ct">

	<tr>
		<td colspan="2" class="ht">All Portfolio</td>
	</tr>

	<tr>
		<td width="100px">&nbsp;</td>
		<td>
		<table width="100%" cellpadding="2" cellspacing="1"
			style="border: 1px solid #80aeff">
			<tr style="background-color: #80aeff">
				<td>Portfolio ID</td>
				<td>Portfolio Name</td>
				<td>Portfolio Owner</td>

			</tr>
			<%
						String username = (String) session
						.getAttribute(STSConstants.SESSION_USER);
				PortfolioEntity[] entities = HandlerFactoryProxy.instance()
						.getPortfolioHandler().getAllPortfolios(username);
				if (entities != null) {
					StringBuffer sb = new StringBuffer();
					for (int i = 0; i < entities.length; i++) {
						PortfolioEntity e = entities[i];
						sb.append("<tr onclick=\"window.location='stock.jsp?portfolio="
						+ e.getId()
						+ "'\" style='cursor:hand' title='Click to open "
						+ e.getName() + "'>");
						sb.append("<td>" + e.getId() + "</td>");
						sb.append("<td>" + e.getName() + "</td>");
						sb.append("<td>" + e.getCustomerName() + "</td>");
						sb.append("</tr>");
					}
					out.println(sb);
				}
			%>
		</table>
		</td>
	</tr>

</table>
<div class="summary">
<div class="summaryc">you have <%=entities == null ? 0 : entities.length%>
portfolios</div>
&nbsp;</div>

<table id="ct" width="100%" cellpadding="2" cellspacing="0" class="ct">
	<tr>
		<td colspan="2" class="ht">Operaions</td>
	</tr>

	<table width="100%" cellpadding="2" cellspacing="1"
		style="border: 1px solid #80aeff">

		<form name="Portfolioadd" method="post" action="Portfolio.do">
		<tr>

			<td><label for="email">Portfolio ID:</label></td>
			<td><input type="text" name="portfolioId" value=""
				id="portfolioId" size="20" /></td>
			<td><label for="email">Portfolio Name:</label></td>
			<td><input type="text" name="portfolioName" id="portfolioName"
				size="20" /></td>
			<td colspan="2" align="right"><input type="submit" name="add"
				value="add">&nbsp;&nbsp; <input type="reset" name="reset"
				value="reset"></td>
		</tr>
		</form>
		<form name="Portfoliodelete" method="post" action="Portfolio.do">
		<tr>

			<td><label for="email">Portfolio ID:</label></td>
			<td><input type="text" name="portfolioId" value=""
				id="portfolioId" size="20" /></td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td colspan="2" align="right"><input type="submit" name="delete"
				value="delete">&nbsp;&nbsp; <input type="reset"
				name="reset" value="reset"></td>
		</tr>
		</form>
	</table>
	
</body>